<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <title>用户登录 - RuoYi</title>
  <style>
    body {
      margin: 0; padding: 0;
      font-family: "Microsoft YaHei", sans-serif;
      background: linear-gradient(135deg, #6b8ce3, #88a9f9);
      height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .login-container {
      background: white;
      padding: 40px 50px;
      border-radius: 8px;
      box-shadow: 0 8px 20px rgba(0,0,0,0.15);
      width: 360px;
    }
    .login-container h2 {
      margin: 0 0 30px;
      text-align: center;
      color: #333;
      font-weight: 600;
    }
    .form-group {
      margin-bottom: 20px;
    }
    label {
      display: block;
      font-size: 14px;
      color: #555;
      margin-bottom: 6px;
    }
    input[type="text"], input[type="password"] {
      width: 100%;
      padding: 10px 12px;
      font-size: 14px;
      border: 1.5px solid #ccc;
      border-radius: 4px;
      box-sizing: border-box;
      transition: border-color 0.3s ease;
    }
    input[type="text"]:focus, input[type="password"]:focus {
      border-color: #4a90e2;
      outline: none;
    }
    .checkbox-group {
      display: flex;
      align-items: center;
      margin-bottom: 25px;
    }
    .checkbox-group input[type="checkbox"] {
      margin-right: 8px;
    }
    .btn-login {
      width: 100%;
      padding: 12px;
      background-color: #4a90e2;
      border: none;
      border-radius: 4px;
      font-size: 16px;
      color: white;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }
    .btn-login:hover {
      background-color: #3577d4;
    }
    .footer {
      margin-top: 20px;
      text-align: center;
      color: #888;
      font-size: 12px;
    }
  </style>
  <!-- 引入 jQuery -->
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

  <script>
    $(document).ready(function() {
      $('#loginForm').submit(function(event) {
        event.preventDefault(); // 阻止默认表单提交

        // 获取表单数据
        var username = $('#username').val();
        var password = $('#password').val();

        // 发送 AJAX 请求
        $.ajax({
          url: '/user/login',       // 后台登录接口地址，替换成你自己的地址
          type: 'POST',

          data: {
            username: username,
            password: password
          }
          ,
          success: function(response) {
            if(response ==='success') {
              alert('登录成功！欢迎，' + response);
              // 登录成功后跳转或处理逻辑
              window.location.href = '/static/d.html';
            } else {
              alert('登录失败：' + response.message);
            }
          },
          error: function(xhr, status, error) {
            alert('服务器错误，请稍后重试！');
            console.error('错误信息:', error);
          }
        });
      });
    });
  </script>
</head>
<body>
<div class="login-container">
  <h2>用户登录</h2>
  <form id="loginForm" onsubmit="return false;">
    <div class="form-group">
      <label for="username">用户名</label>
      <input type="text" id="username" name="username" placeholder="请输入用户名" required />
    </div>
    <div class="form-group">
      <label for="password">密码</label>
      <input type="password" id="password" name="password" placeholder="请输入密码" required />
    </div>
    <div class="checkbox-group">
      <input type="checkbox" id="rememberMe" name="rememberMe" />
      <label for="rememberMe">记住我</label>
    </div>
    <button type="submit" class="btn-login" >登录</button>
  </form>
  <div class="footer">&copy; 2025 RuoYi 版权所有</div>
</div>
</body>
</html>